<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Sa-Token-SSO-Client端-测试页（前后端分离版-原生h5）</title>
	</head>
	<body>
		<h2>Sa-Token SSO-Client 应用端（前后端分离版-原生h5）</h2>
		<p>当前是否登录：<b class="is-login"></b></p>
		<p>
			<a href="javascript: login();">登录</a> - 
			<a href="javascript: doLogoutByAlone();">单应用注销</a> - 
			<a href="javascript: doLogoutBySingleDeviceId();">单浏览器注销</a> - 
			<a href="javascript: doLogout();">全端注销</a> - 
			<a href="javascript: doMyInfo();">账号资料</a>
		</p>
		<script src="sso-common.js"></script>
		<script type="text/javascript">
			
			// 登录 
			function login() {
				location.href = 'sso-login.html?back=' + encodeURIComponent(location.href);
			}
			
			// 单应用注销
			function doLogoutByAlone() {
				ajax('/sso/logoutByAlone', {}, function(res){
					doIsLogin();
				})
			}
			
			// 单浏览器注销
			function doLogoutBySingleDeviceId() {
				ajax('/sso/logout', { singleDeviceIdLogout: true }, function(res){
					doIsLogin();
				})
			}
			
			// 全端注销
			function doLogout() {
				ajax('/sso/logout', {  }, function(res){
					doIsLogin();
				})
			}
			
			// 账号资料
			function doMyInfo() {
				ajax('/sso/myInfo', {  }, function(res){
					alert(JSON.stringify(res));
				})
			}
			
			// 判断是否登录 
			function doIsLogin() {
				ajax('/sso/isLogin', {}, function(res){
					if(res.data) {
						setHtml('.is-login', res.data + ' (' + res.loginId + ')');
					} else {
						setHtml('.is-login', res.data);
					}
				})
			}
			doIsLogin();
			
		</script>
	</body>
</html>
